#include <linux/module.h>   // required by all modules
#include <linux/kernel.h>   // required by printk()
#include <linux/init.h>
#include <net/protocol.h>
#include <net/tcp.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Tang Li");

static struct net_protocol tcp_protocol = {
	.handler = tcp_v4_rcv,
        .err_handler =  0,//tcp_v4_err,
        .gso_send_check = 0,//tcp_v4_gso_send_check,
        .gso_segment =  0,//tcp_tso_segment,
        .no_policy =    1,
        .netns_ok =     1,
};

// Start/Init function
static int newproc_init(void) {
        
	printk(KERN_CRIT "Hello Alex Tang!\n Welcome to Module World\n");  // A logging mechanism for kernel
	if (inet_add_protocol(&tcp_protocol, 253) < 0)
		printk(KERN_CRIT "Cannot add New TCP protocol\n");
	return 0;                             // A non-zero return means hello_init failed; the module can't be loaded.
}

// End/Cleanup function
static void newproc_exit(void) {
    	printk(KERN_CRIT "Goodbye Alex Tang!\n");
}

module_init(newproc_init);
module_exit(newproc_exit);

